// addKeyModel.tsx

import { Modal, Input } from "antd";

// 添加key弹窗
export function addKeyModel(title = "请输入key") {
    return new Promise<string>((resolve, reject) => {
        let content = "";
        Modal.confirm({
            title: title,
            centered: true,
            content: (
                <div>
                    <Input
                        placeholder={title}
                        maxLength={200}
                        onChange={e => {
                            content = e.target.value
                        }}
                    />
                </div>
            ),
            cancelText: "取消",
            onCancel() {
                resolve("");
            },
            okText: "确定",
            onOk() {
                if (content) {
                    resolve(content);
                } else {
                    reject();
                }
            }
        });

    });
}